package com.zhh.springcloud.controller;

import com.zhh.springcloud.feignService.FeignService;
import com.zhh.springcloud.model.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//消费者层的feign controller
@RestController
@RequestMapping("/consumer")
public class FeignConsumerController {

    @Autowired
    public FeignService feignService;

    @PostMapping("/add")
    public Integer add(@RequestBody Department department){
        return feignService.add(department);
    }

    @GetMapping("delete")
    public int delete(@RequestParam(value = "id", required = false) int id){
        return feignService.delete(id);
    }

    @PostMapping("/modify")
    public int modify(@RequestBody Department department){
        return feignService.modify(department);
    }

    @GetMapping("/get")
    public Department get(@RequestParam(value = "id", required = false) int id){
        return feignService.getById(id);
    }

    @GetMapping("/getall")
    public List<Department> getall(){
        return feignService.getAll();
    }
}
